package com.example.tyz1201.myaccount.Activity.Activity.Adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.tyz1201.myaccount.Activity.Activity.Model.AssumeModel;
import com.example.tyz1201.myaccount.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by tyz1201 on 2016/4/8.
 */
public class AssumeAdapter extends BaseAdapter {
    List<AssumeModel> messages = new ArrayList<>();
    Context context;

    public AssumeAdapter(List<AssumeModel> messages, Context context) {
        this.messages = messages;
        this.context = context;
    }

    @Override
    public int getCount() {
        return messages.size();
    }

    @Override
    public Object getItem(int position) {
        return messages.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.item_icon, parent, false);

        TextView tv_tips = (TextView) view.findViewById(R.id.tv_tips);
        tv_tips.setText(messages.get(position).getChoosedName());

        TextView tv_todomoney = (TextView) view.findViewById(R.id.tv_todomoney);
        tv_todomoney.setText(messages.get(position).getTodoMoney() + "");

        /**
         * 为什么不用浮点数的原因：？？
         */
        return view;
    }
}
